package star.搜索与回溯.求和;

public class SumNums {
    public static void main(String[] args) {
        System.out.println(new SumNums().sumNums(9));
    }
    int res = 0;
    public int sumNums(int n){
        res = n > 1 ? n + sumNums(n-1) : 1;
        return res;
    }
    /*public int sumNums(int n) {
        boolean x = n > 1 && sumNums(n - 1) > 0;
        res += n;
        return res;
    }*/
}
